import React from 'react';
import {DatePicker} from 'antd';
import store from './store'
import {getTimeParams } from './store/actionCreators'
const { RangePicker, } = DatePicker;
const dateFormat = 'YYYY-MM-DD HH:mm'||undefined;
export default class TestHeader extends React.Component{
    state={
    }
    onPickerChange =(date, dateString)=> {
        this.setState({
            beginDate: dateString[0],
            endDate: dateString[1],
        },()=>{
            let obj={
                beginDate: dateString[0],
                endDate: dateString[1],
            }
            const action = getTimeParams(obj)  //在这里传递给action参数
            store.dispatch(action)             //通过dispatch改变store状态
        })
    }

    render(){
        return(
            <div>
                <RangePicker
                    onChange={this.onPickerChange}
                    showTime={{ format: 'HH:mm' }}
                    format={dateFormat}
                    placeholder={['开始时间','结束时间']}
                />
            </div>
        )
    }
}
